//
//  Extension+UIBarButtonItem .swift
//  YMWeiBo
//
//  Created by mimi on 16/7/19.
//  Copyright © 2016年 mimi. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    
   convenience init(title:String? = nil ,imgName:String? = nil,targe:AnyObject ,action:Selector) {
        self.init()
    
    let bt:UIButton = UIButton()
    
    if let tit = title {
        bt.setTitle(tit, forState: .Normal)
        bt.titleLabel?.font = UIFont.systemFontOfSize(15)
        bt.setTitleColor(UIColor.orangeColor(), forState: .Normal)
        bt.setTitleColor(UIColor.darkGrayColor(), forState: .Disabled)
     
        
    }
    
    if let img = imgName {
        
        bt.setImage(UIImage(named: img), forState: .Normal)
        
    }
    
    bt.addTarget(targe, action: action, forControlEvents: .TouchUpInside)
    bt.sizeToFit()
    self.customView = bt
    
    }
    
    
}
